package org.kealinghornets.jchuah.buttons;

import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;


public class Level_3_Activity extends Level_2_Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_level_3_);
    }

    public void checkVictory() {
        View leftstar=(findViewById(R.id.topLeft_star));
        View midstar=(findViewById(R.id.topMid_star));
        View rightstar=(findViewById(R.id.topRight_star));
        View botleftstar=(findViewById(R.id.botLeft_star));
        View botmidstar=(findViewById(R.id.botMid_star));
        View botrightstar=(findViewById(R.id.botRight_star));
        if (leftstar.getVisibility() == View.INVISIBLE && midstar.getVisibility() == View.INVISIBLE && rightstar.getVisibility() == View.INVISIBLE && botleftstar.getVisibility() == View.INVISIBLE && botmidstar.getVisibility() == View.INVISIBLE && botrightstar.getVisibility() == View.INVISIBLE) {
            Log.d("u1", "u2");
            Toast.makeText(this, "U3", Toast.LENGTH_SHORT).show();
            startActivity(new Intent(this, Winning_Screen.class));
        }
    }

    @Override
    public void onLeft_buttonPush(View view) {
        Log.d("top left","");
        toggleVisibility(R.id.topRight_star);
        toggleVisibility(R.id.botMid_star);
    }

    @Override
    public void onMiddle_buttonPush(View view) {
        Log.d("top mid","");
        toggleVisibility(R.id.topRight_star);
        toggleVisibility(R.id.botRight_star);
        checkVictory();
    }

    @Override
    public void onRight_buttonPush(View view) {
        Log.d("top right","");
        toggleVisibility(R.id.topMid_star);
        toggleVisibility(R.id.botMid_star);
        checkVictory();
    }

    @Override
    public void onbotLeft_buttonPush(View view) {
        Log.d("bot left","");
        toggleVisibility(R.id.botLeft_star);
        toggleVisibility(R.id.topLeft_star);
        checkVictory();
    }

    @Override
    public void onbotMid_buttonPush(View view) {
        Log.d("bot mid","");
        toggleVisibility(R.id.botMid_star);
        toggleVisibility(R.id.botLeft_star);
        toggleVisibility(R.id.topLeft_star);
        checkVictory();
    }

    @Override
    public void onbotRight_buttonPush(View view) {
        Log.d("bot right","");
        toggleVisibility(R.id.botRight_star);
        toggleVisibility(R.id.topLeft_star);
        checkVictory();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_level_3_, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
